package com.icinfo.cloud.provider.punish.ucase.casemain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.ObjectUtils;

/**
 * 描述：统一案件查询处罚种类枚举
 *
 * @author yehuafei
 * @date 2022-04-09 14:21
 */
@AllArgsConstructor
public enum PunishKindsEnum {
    /**
     * 案件涉及枚举
     */
    PunishKind_1("1",	"警告"),
    PunishKind_2("2",	"罚款"),
    PunishKind_3("3",	"没收违法所得"),
    PunishKind_4("4",	"责令停产停业"),
    PunishKind_5("5",	"暂扣或吊销许可证"),
    PunishKind_6("6",	"行政拘留"),
    PunishKind_7("7",	"法律"),
    PunishKind_99("99",	"行政法规规定的其他行政处罚");

    /**
     * 编码
     */
    @Getter
    private String code;
    /**
     * 描述
     */
    @Getter
    private String des;

    /**
     * 描述：根据code获取value
     *
     * @param code 编码
     * @return 描述内容
     * @author yehaufei
     * @date 2022-02-22 10:43
     */
    public static String getValueByCode(String code) {
        if (ObjectUtils.isEmpty(code)) {
            return null;
        }
        for (PunishKindsEnum e : PunishKindsEnum.values()) {
            if (code.equals(e.getCode())) {
                return e.getDes();
            }
        }
        return code;
    }

    /**
     * 描述：校验code是否是合法枚举
     *
     * @param code 枚举code
     * @return boolean 是否合法枚举（true-是/false-否）
     * @author yehuafei
     * @date 2022-02-22 10:42
     */
    public static boolean isLegalEnumCode(String code) {
        boolean flag = false;
        for (PunishKindsEnum e : PunishKindsEnum.values()) {
            if (e.getCode().equalsIgnoreCase(code)) {
                flag = true;
                break;
            }
        }
        return flag;
    }
}
